<?php
$section = "member";
$titre = _LB_ACCOUNT_MANAGEMENT;
$link = $section;
if(!isMemberLoggedIn()){
	redirect(APPLICATION_URL_FO."/");
}
//get object ID
$id = Request::getIntNumber('id');
$act = Request::getIntNumber('act');
if ($act == ACT_VALID_EDIT)
{
	$login = $_POST['login'];
	$pwd = $_POST['pwd'];
	$acces = new Member();
	$acces->whereAdd("EMAIL = '" . mysql_real_escape_string($login) . "'");
	$acces->whereAdd("PASS = '" . sha1(mysql_real_escape_string($pwd)) . "'");


	$acces->DISABLED = 0;
	$acces->find();
   
	if ($acces->fetch()){
		$acces->updateMember();
		$_SESSION["memberID"] = $acces->ID;
		redirect(APPLICATION_URL_FO."/");
	}
	else{
	}
}

$sql = "SELECT COUNT(DISTINCT  B.ID) NB_BOOKING FROM BOOKING B
			INNER JOIN BOOKING_DETAIL BD ON BD.ID_BOOKING = B.ID
			WHERE B.ID_MEMBER = '".$_SESSION["memberID"]."' 
			AND BD.BOOKING_DATE >= '".date("Y-m-d")."' AND B.STATUS = 1";
$icBooking = new Booking();
$icBooking->query($sql);
$icBooking->fetch();


$sql = "SELECT COUNT(DISTINCT  B.ID) NB_BOOKING FROM BOOKING B
			INNER JOIN BOOKING_DETAIL BD ON BD.ID_BOOKING = B.ID
			WHERE B.ID_MEMBER = '".$_SESSION["memberID"]."' 
			AND BD.BOOKING_DATE >= '".date("Y-m-d")."' AND B.STATUS = 0";
$wBooking = new Booking();
$wBooking->query($sql);
$wBooking->fetch();
//create cfer
$cfer = new Cfer(array(
	_LB_ACCUEIL => APPLICATION_URL_FO,
	_LB_LOGIN => Utils::getCurrentLink()));

//if validate is false, display form again
$smarty->assign('cfer', $cfer);
$smarty->assign("incommingBooking",$icBooking->NB_BOOKING);
$smarty->assign("waitingBooking",$wBooking->NB_BOOKING);
$smarty->display('member_panel.html');
/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

